package main

import (
	"bufio"
	"fmt"
	"gameserver/tools/TestRobot/cmd"
	_ "gameserver/tools/TestRobot/logic"
	"gameserver/tools/TestRobot/models"
	"os"

	"gitee.com/night-tc/gobige/sess"
)

/*
测试机器人
*/

func init() {
	tmp := sess.GetServer_key()
	sess.SetServer_key(sess.GetClient_key())
	sess.SetClient_key(tmp)
}

func SendMain() {
	curr := 0
	send := ""
	input := bufio.NewScanner(os.Stdin)
	for {
		curr++
		fmt.Printf("curr(%v)\\> ", curr)
		if !input.Scan() {
			return
		}
		send = input.Text()
		inputcmd := cmd.GetCmdMgr().SendCmd(send)
		if inputcmd == nil {
			continue
		}
		if inputcmd.Cmd.Runf != nil {
			models.GetRobotMgr().AddCmd(inputcmd)
		} else if inputcmd.Cmd.Parsef != nil {
			if inputcmd.Cmd.Parsef(inputcmd) {
				models.GetRobotMgr().AddCmd(inputcmd)
			}
		}

	}
}
